<template>
	<!-- 店铺 -->
	<view>
		<view class="header">
			<image :src="db.images[0]" mode="aspectFill" style="border-radius: 10rpx;"></image>
			<view>
				<view class="name">{{db.name}}</view>
				<view class="msg_add">
					<view class="msg">
						<image :src="vuex_httpImageUrl && vuex_httpImageUrl+'static/common/iconshop.png'" mode="widthFix"></image>
					{{db.content}}+{{db.business}}</view>
					<view style="
						display: flex;
						align-items: center;
						margin-top: 15rpx;
					" >
						<image :src="vuex_httpImageUrl && vuex_httpImageUrl+'static/common/iconaddress.png'" mode="widthFix"></image>
						{{db.address}}
					</view>
				</view>
			</view>
			<image @click="cardPhone" :src="vuex_httpImageUrl && vuex_httpImageUrl+'static/common/iconphone.png'" class="phone" mode="widthFix"></image>
		</view>
		<!-- nav -->
	<!-- 	<view class="nav">
			<text v-for="(item,index) in nav" :key="index"
				:class="navActive == index?'active':''"
				@click="navActive = index"
			>{{item}}</text>
		</view> -->
		
		<!-- list -->
		<view class="list" v-if="navActive == 0">
			<view v-for="(item,index) in db.local" :key="index" @click="C_listItem(item)" >
				<image :src="item.images[0]" mode="aspectFill" style="border-radius: 10rpx;"></image>
				<view>
					<view class="name">{{item.name}}</view>
					<view>
						<view class="msg">{{item.intro}}</view>
						<view class="price">￥{{item.price}}/{{item.goods_format}}</view>
					</view>
				</view>
			</view>
		</view>
		
		<!-- 评论 -->
		<view class="comment" v-if="navActive == 1">
			<view v-for="(item,index) in comment" :key="index">
				<image class="avatar" :src="item.avatar" mode="aspectFill"></image>
				<view class="cont">
					<view class="top">
						<text>{{item.name}}</text>
						<view>
							<text>{{item.time}}</text>
							<text v-if="item.evaluate == 0">差评</text>
							<text v-if="item.evaluate == 1">中评</text>
							<text v-if="item.evaluate == 2" style="color: #FA982D;">好评</text>
						</view>
					</view>
					<view class="msg">{{item.msg}}</view>
					<view class="images">
						<image v-for="(item,index) in item.images" :key="index" :src="item"></image>
					</view>
					<view class="serve">
						<image :src="item.serve.thumb" mode="widthFix"></image>
						<view>
							<view>{{item.serve.name}}</view>
							<text>{{item.serve.msg}}</text>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				header:{},
				// nav:['首页','评价'],
				navActive:0,
				comment:[],
				
				db:{}
			};
		},
		onLoad(o) {
			this.def_list(o.id)
		},
		onShow() {
			
		},
		methods:{
			cardPhone(){
				if(!this.db.phone){
					this.$u.toast('当前店铺没有手机号')
					return
				}
				uni.makePhoneCall({
					phoneNumber:this.db.phone
				})
			},
			def_list(localshop_id){
				this.$u.post('/local/local',{
					localshop_id
				}).then(res=>{
					this.db = res.data
					uni.setNavigationBarTitle({
						title:res.data.name
					})
				})
				
				let url = this.vuex_httpImageUrl;
				this.comment = [
					{
						avatar:url+"static/index/test/thumb.png",
						name:'微信昵称',
						time:'2021-01-01',
						evaluate:2,  //0差评1中评2好评
						msg:'服务质量不错！服务质量不错！服务质量不错！服务质量不错！服务质量不错！',
						images:[
							url+"static/index/test/thumb.png",
							url+"static/index/test/thumb.png",
							url+"static/index/test/thumb.png",
							url+"static/index/test/thumb.png",
							url+"static/index/test/thumb.png",
							url+"static/index/test/thumb.png",
							url+"static/index/test/thumb.png",
							url+"static/index/test/thumb.png",
						],
						serve:{
							thumb:url+"static/index/test/thumb.png",
							name:'服务名称',
							msg:'单人局部按摩'
						}
					}
				]
			},
			C_listItem(item){
				uni.navigateTo({
					url:'./detail/detail?db='+encodeURIComponent(JSON.stringify(item))
				})
			}
		}
	}
</script>

<style lang="scss">
	.msg_add{
		image{
			width: 30rpx;
			height: 30rpx;
			margin-right: 20rpx;
		}
	}
	.header{
		display: flex;
		padding: 30rpx;
		background:linear-gradient(#3174E9,#3599EE);
		color: #FFFFFF;
		position: sticky;
		// top: 80rpx;
		z-index: 1;
		>image{
			width: 150rpx;
			height: 150rpx;
			margin-right: 20rpx;
		}
		.phone{
			position: absolute;
			bottom: 25rpx;
			right: 0;
			width: 65rpx;
			height: 65rpx;
		}
		>view{
			display: flex;
			flex-direction: column;
			justify-content: space-between;
			flex: 1;
			.name{
				font-weight: bold;
				font-size: 35rpx;
			}
		}
	}

	.nav{
		width: 95%;
		margin: 30rpx auto;
		font-size: 35rpx;
		text{
			display: inline-block;
			text-align: center;
			width: 120rpx;
			&.active{
				font-weight: bold;
				position: relative;
				&::before{
					content: '';
					position: absolute;
					bottom: -18rpx;
					left: 30%;
					width: 50rpx;
					height: 10rpx;
					border-radius: 50rpx;
					background:linear-gradient(#3174E9,#3599EE);
					
				}
			}
		}
	}

	.list{
		background-color: #FFFFFF;
		border-radius: 20rpx;
		width: 95%;
		margin: auto;
		padding: 20rpx;
		>view{
			margin-bottom: 20rpx;
			display: flex;
			>view{
				flex: 1;
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				.name{
					font-weight: bold;
				}
				.msg{
					font-size: 24rpx;
					color: gray;
				}
				.price{
					color: #E92A23;
					font-weight: bold;
				}
			}
			
			image{
				width: 120rpx;
				height: 120rpx;
				margin-right: 20rpx;
			}
		}
	}

	.comment{
		width: 95%;
		margin: auto;
		background-color: #FFFFFF;
		padding: 20rpx;
		box-sizing: border-box;
		border-radius: 20rpx;
		>view{
			display: flex;
			.avatar{
				width: 80rpx;
				height: 80rpx;
				border-radius: 50%;
				margin-right: 20rpx;
			}
			.cont{
				flex: 1;
				margin-top: 20rpx;
				>view{
					margin-bottom: 20rpx;
					&.top{
						display: flex;
						justify-content: space-between;
					}
					&.images{
						display: grid;
						grid-template-columns:repeat(4,1fr);
						grid-gap:20rpx;
						image{
							width: 120rpx;
							height: 120rpx;
							margin: auto;
						}
					}
					&.serve{
						display: flex;
						background-color: #F4F4F4;
						padding: 20rpx;
						image{
							width: 80rpx;
							height: 80rpx;
							border-radius: 10rpx;
							margin-right: 20rpx;
						}
						>view{
							flex: 1;
							display: flex;
							flex-direction: column;
							justify-content: space-between;
						}
					}
				}
				
			}
		}
	}
</style>
